package io.ganguo.chat.core.util;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import java.util.ArrayList;
import java.util.Objects;

/**
 * Created by hasee on 2016-03-28.
 */
public class JsonUtil {
    public static JSONObject Array2Json(ArrayList objects) {

        JSONArray array = JSONArray.fromObject(objects);
        JSONObject object = new JSONObject();
        object.put("array", array);
        return object;
    }

    public static Object[] Json2Array(JSONObject jsonObject) {
        JSONArray array = jsonObject.getJSONArray("array");

        return array.toArray();
    }
}
